package com.mirabelle.juice.model;

import java.io.Serializable;
import javax.persistence.*;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the recipe database table.
 * 
 */
@Entity
@Table(name="recipe")
public class Recipe implements Serializable {
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String comment;
	private Date created;
	private Date modified;
	private String name;
	private Integer rating;
	private List<Additive> additives;
	private List<Aroma> aromas;
	private Author author;
	private List<Base> bases;
	private Collection collection;
	private List<Comment> comments;
	private List<UseAdditive> useAdditives;
	private List<UseAroma> useAromas;
	private List<UseBase> useBases;

	public Recipe() {
	}


	@Id
	@SequenceGenerator(name="RECIPE_ID_GENERATOR", sequenceName="SEQ_RECIPE_ID")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="RECIPE_ID_GENERATOR")
	@Column(unique=true, nullable=false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}


	@Column(length=2147483647)
	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}


	@Temporal(TemporalType.DATE)
	@Column(nullable=false)
	public Date getCreated() {
		return this.created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}


	@Temporal(TemporalType.DATE)
	@Column(nullable=false)
	public Date getModified() {
		return this.modified;
	}

	public void setModified(Date modified) {
		this.modified = modified;
	}


	@Column(nullable=false, length=255)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public Integer getRating() {
		return this.rating;
	}

	public void setRating(Integer rating) {
		this.rating = rating;
	}
	
	//bi-directional many-to-one association to Comment
	@OneToMany(mappedBy="recipe") 
	public List<Comment> getComments() {
		return this.comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	public Comment addComment(Comment comment) {
		getComments().add(comment);
		comment.setRecipe(this);

		return comment;
	}

	public Comment removeComment(Comment comment) {
		getComments().remove(comment);
		comment.setRecipe(null);

		return comment;
	}


	//bi-directional many-to-many association to Additive
	@ManyToMany
	@JoinTable(
		name="use_additive"
		, joinColumns={
			@JoinColumn(name="recipe_id", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="additive_id", nullable=false)
			}
		)
	public List<Additive> getAdditives() {
		return this.additives;
	}

	public void setAdditives(List<Additive> additives) {
		this.additives = additives;
	}


	//bi-directional many-to-many association to Aroma
	@ManyToMany
	@JoinTable(
		name="use_aroma"
		, joinColumns={
			@JoinColumn(name="recipe_id", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="aroma_id", nullable=false)
			}
		)
	public List<Aroma> getAromas() {
		return this.aromas;
	}

	public void setAromas(List<Aroma> aromas) {
		this.aromas = aromas;
	}


	//bi-directional many-to-one association to Author
	@ManyToOne
	@JoinColumn(name="author_id", nullable=false)
	public Author getAuthor() {
		return this.author;
	}

	public void setAuthor(Author author) {
		this.author = author;
	}


	//bi-directional many-to-many association to Base
	@ManyToMany
	@JoinTable(
		name="use_base"
		, joinColumns={
			@JoinColumn(name="recipe_id", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="base_id", nullable=false)
			}
		)
	public List<Base> getBases() {
		return this.bases;
	}

	public void setBases(List<Base> bases) {
		this.bases = bases;
	}


	//bi-directional many-to-one association to Collection
	@ManyToOne
	@JoinColumn(name="collection_id", nullable=false)
	public Collection getCollection() {
		return this.collection;
	}

	public void setCollection(Collection collection) {
		this.collection = collection;
	}


	//bi-directional many-to-one association to UseAdditive
	@OneToMany(mappedBy="recipe")
	public List<UseAdditive> getUseAdditives() {
		return this.useAdditives;
	}

	public void setUseAdditives(List<UseAdditive> useAdditives) {
		this.useAdditives = useAdditives;
	}

	public UseAdditive addUseAdditive(UseAdditive useAdditive) {
		getUseAdditives().add(useAdditive);
		useAdditive.setRecipe(this);

		return useAdditive;
	}

	public UseAdditive removeUseAdditive(UseAdditive useAdditive) {
		getUseAdditives().remove(useAdditive);
		useAdditive.setRecipe(null);

		return useAdditive;
	}


	//bi-directional many-to-one association to UseAroma
	@OneToMany(mappedBy="recipe")
	public List<UseAroma> getUseAromas() {
		return this.useAromas;
	}

	public void setUseAromas(List<UseAroma> useAromas) {
		this.useAromas = useAromas;
	}

	public UseAroma addUseAroma(UseAroma useAroma) {
		getUseAromas().add(useAroma);
		useAroma.setRecipe(this);

		return useAroma;
	}

	public UseAroma removeUseAroma(UseAroma useAroma) {
		getUseAromas().remove(useAroma);
		useAroma.setRecipe(null);

		return useAroma;
	}


	//bi-directional many-to-one association to UseBase
	@OneToMany(mappedBy="recipe")
	public List<UseBase> getUseBases() {
		return this.useBases;
	}

	public void setUseBases(List<UseBase> useBases) {
		this.useBases = useBases;
	}

	public UseBase addUseBas(UseBase useBas) {
		getUseBases().add(useBas);
		useBas.setRecipe(this);

		return useBas;
	}

	public UseBase removeUseBas(UseBase useBas) {
		getUseBases().remove(useBas);
		useBas.setRecipe(null);

		return useBas;
	}

}